﻿<Window x:Class="ScrumSprintMonitor.ConfigEditor.Views.ConfigurationView.ConfigurationWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:ScrumSprintMonitor.ConfigEditor"
    xmlns:ConfigurationView="clr-namespace:ScrumSprintMonitor.ConfigEditor.Views.ConfigurationView"
    xmlns:converters="clr-namespace:ScrumSprintMonitor.ConfigEditor.Converters"
    Title="Configure Scrum Sprint Monitor"
    Background="Gray"
    Width="600" WindowStartupLocation="CenterScreen"
    Loaded="Window_Loaded" Activated="Window_Activated" MouseLeftButtonDown="Window_MouseLeftButtonDown">
    
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/ScrumSprintMonitor.UI.Wpf;component/Styles/FormResourceDictionary.xaml" />
            </ResourceDictionary.MergedDictionaries>

            <local:XamlServiceLocator x:Key="serviceLocator" />
            
            <converters:NegatedValueConverter x:Key="NegatedValueConverter" />
        </ResourceDictionary>
    </Window.Resources>

    <Window.Style>
        <StaticResource ResourceKey="DefaultChrome"/>
    </Window.Style>
    
    <DockPanel DataContext="{Binding Path=ConfigurationViewModel, Source={StaticResource serviceLocator}}">
        <Grid DockPanel.Dock="Top">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <Label Style="{StaticResource LabelStyle}" Grid.Column="0" Grid.Row="0" Content="_Team Foundation Server:" Target="{Binding ElementName=tfsServerNameComboBox}" />
            <ComboBox Grid.Column="1" Grid.Row="0" ItemsSource="{Binding Path=AvailableTfsServers}" SelectedItem="{Binding Path=TfsServerName}" x:Name="tfsServerNameComboBox" IsReadOnly="{Binding IsConfigurationWritable, Converter={StaticResource NegatedValueConverter}}" />

            <ContentControl Grid.Row="1" Grid.ColumnSpan="2" ContentTemplate="{StaticResource Separator}" Content="Current Sprint" IsTabStop="False" Focusable="False" />

            <Label Style="{StaticResource LabelStyle}" Grid.Column="0" Grid.Row="2" Content="_Configuration File:" Target="{Binding ElementName=configurationFileTextBox}" />
            <Grid Grid.Column="1" Grid.Row="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                <TextBox x:Name="configurationFileTextBox" Style="{StaticResource TextBoxStyle}" Grid.Column="0" Text="{Binding Path=ConfigurationFilePath}" IsReadOnly="{Binding IsConfigurationWritable, Converter={StaticResource NegatedValueConverter}}" />
                <Button Command="{Binding BrowseSprintConfigurationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ConfigurationView:ConfigurationWindow}}}" Grid.Column="1" Content="..." Padding="6,0" Margin="0,2" IsEnabled="{Binding IsConfigurationWritable}" />
            </Grid>
            <Button Command="{Binding EditSprintConfigurationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ConfigurationView:ConfigurationWindow}}}" Grid.Row="3" Grid.ColumnSpan="2" HorizontalAlignment="Right" Content="Edit _Sprint Configuration..." Padding="6" Margin="0,2" />

            <ContentControl Grid.Row="4" Grid.ColumnSpan="2" ContentTemplate="{StaticResource Separator}" Content="Team Members" IsTabStop="False" Focusable="False" />

            <Label Style="{StaticResource LabelStyle}" Grid.Column="0" Grid.Row="5" Content="Configuration File:" Target="{Binding ElementName=teamMembersConfigurationTextBox}"/>
            <Grid Grid.Column="1" Grid.Row="5">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                <TextBox x:Name="teamMembersConfigurationTextBox" Style="{StaticResource TextBoxStyle}" Grid.Column="0" Text="{Binding Path=TeamMembersConfigurationFilePath}" IsReadOnly="{Binding IsConfigurationWritable, Converter={StaticResource NegatedValueConverter}}" />
                <Button Command="{Binding BrowseTeamMembersConfigurationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ConfigurationView:ConfigurationWindow}}}" Grid.Column="2" Content="..." Padding="6,0" Margin="0,2" IsEnabled="{Binding IsConfigurationWritable}" />
            </Grid>
            <Button Command="{Binding EditTeamMembersConfigurationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ConfigurationView:ConfigurationWindow}}}" Grid.Row="6" Grid.ColumnSpan="2" HorizontalAlignment="Right" Content="Edit in Microsoft E_xcel 2007..." Padding="6" Margin="0,2" />

            <ContentControl Grid.Row="7" Grid.ColumnSpan="2" ContentTemplate="{StaticResource Separator}" Content="General Presentation Options" IsTabStop="False" Focusable="False" />

            <Label Style="{StaticResource LabelStyle}" Grid.Column="0" Grid.Row="8" Content="Configuration File:" Target="{Binding ElementName=presentationConfigurationTextBox}"/>
            <Grid Grid.Column="1" Grid.Row="8">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                <TextBox x:Name="presentationConfigurationTextBox" Style="{StaticResource TextBoxStyle}" Grid.Column="0" Text="{Binding Path=PresentationConfigurationFilePath}" IsReadOnly="{Binding IsConfigurationWritable, Converter={StaticResource NegatedValueConverter}}" />
                <Button Command="{Binding BrowsePresentationConfigurationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ConfigurationView:ConfigurationWindow}}}" Grid.Column="2" Content="..." Padding="6,0" Margin="0,2" IsEnabled="{Binding IsConfigurationWritable}" />
            </Grid>
            <Button Command="{Binding EditPresentationConfigurationCommand}" CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ConfigurationView:ConfigurationWindow}}}" Grid.Row="9" Grid.ColumnSpan="2" HorizontalAlignment="Right" Content="Edit _General Options..." Padding="6" Margin="0,2" />

            <Expander Grid.Row="10" Grid.ColumnSpan="2" Header="_Outlook Integration" Foreground="White" HeaderTemplate="{StaticResource ExpanderSeparator}">
                <StackPanel>
                    <CheckBox x:Name="enableOutlookIntegrationCheckBox" IsChecked="{Binding Path=EnableOutlookIntegration}" Margin="6" IsEnabled="{Binding IsConfigurationWritable}">
                        <Label Style="{StaticResource LabelStyle}" Content="Enable Outlook integration for _Free/Busy information" Margin="0" Padding="0" Foreground="White" Target="{Binding ElementName=enableOutlookIntegrationCheckBox}" />
                    </CheckBox>
                    <CheckBox x:Name="considerOutlookTentativeAsFreeTimeCheckBox" IsChecked="{Binding Path=ConsiderOutlookTentativeAsFreeTime}" IsEnabled="{Binding IsConsiderOutlookTentativeAsFreeTimeEnabled}" Margin="6">
                        <Label Style="{StaticResource LabelStyle}" Content="Consider 'Tentative' _appointments to be free time" Margin="0" Padding="0" Foreground="White" Target="{Binding ElementName=considerOutlookTentativeAsFreeTimeCheckBox}" />
                    </CheckBox>
                </StackPanel>
            </Expander>

            <Expander Grid.Row="11" Grid.ColumnSpan="2" Header="_Miscellaneous" Foreground="White" HeaderTemplate="{StaticResource ExpanderSeparator}">
                <StackPanel>
                    <CheckBox x:Name="reportUnestimatedSprintBacklogItemsCheckBox" IsChecked="{Binding Path=ReportUnestimatedSprintBacklogItems}" Margin="6" IsEnabled="{Binding IsConfigurationWritable}">
                        <Label Style="{StaticResource LabelStyle}" Content="Report _unestimated sprint backlog items" Margin="0" Padding="0" Foreground="White" Target="{Binding ElementName=reportUnestimatedSprintBacklogItemsCheckBox}" />
                    </CheckBox>
                       
                    <CheckBox x:Name="inPlanningModeCheckBox" IsChecked="{Binding Path=InPlanningMode}" Margin="6" IsEnabled="{Binding IsConfigurationWritable}">
                        <Label Style="{StaticResource LabelStyle}" Content="_Planning Mode" Margin="0" Padding="0" Foreground="White" Target="{Binding ElementName=inPlanningModeCheckBox}" />
                    </CheckBox>
                </StackPanel>
            </Expander>
        </Grid>

        <Grid DockPanel.Dock="Bottom">
            <Button Command="{Binding ViewLogFileCommand}" CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ConfigurationView:ConfigurationWindow}}}" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="0,0,6,0" Padding="16,4" Content="View _Log File..."/>
            
            <StackPanel DockPanel.Dock="Bottom" HorizontalAlignment="Right" Orientation="Horizontal" VerticalAlignment="Bottom" Margin="0,12,0,0">
                <Button Command="{Binding OkCommand}" CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ConfigurationView:ConfigurationWindow}}}" Margin="6,0,0,0" Padding="16,4" IsDefault="True" Content="O_K"/>
                <Button Command="{Binding CancelCommand}" CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ConfigurationView:ConfigurationWindow}}}" Margin="6,0,0,0" Padding="16,4" IsCancel="True" Content="Cancel"/>
            </StackPanel>
        </Grid>
    </DockPanel>
</Window>
